<template>
	<view class="container">
		<swiper class="swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(item,index) in imgList" :key="index">
				<image style="width: 100%;height: 100%;" :src="item.imgFile" :mode="scaleToFill"
					@click="clickCarousel(item)"></image>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgList: [],
				param: {
					order: "",
					orderBy: "",
					pageNum: 1,
					pageSize: 5,
					searchPARAM: {
						id: "",
						imgFile: "",
						introduce: "",
						name: "",
						type: "",
						url: ""
					}
				}
			}
		},
		created() {
			uni.request({
				url: this.$api + '/carousel/page',
				header: {
					'content-type': 'application/json' //自定义请求头信息
				},
				method: 'POST',
				data: this.param,
				//请求成功后返回
				success: (res) => {
					// 请求成功之后将数据给Info
					if (res.data.code === '200') {
						this.imgList = res.data.data.records;

						this.imgList.forEach((carousel) => {
							carousel.imgFile = this.$api + '/img/' + carousel.imgFile
							// this.imgList.push(this.$api+'/img/'+carousel.imgFile)

						})

					}
				}
			});
		},
		methods: {
			clickCarousel(e) {
				console.log(e.url);
			}
		}

	}
</script>

<style>

</style>
